function request(url, method = "GET", data = {}, header = {}) {
    return new Promise((resolve, reject) => {
        wx.request({
            url,
            method,
            data,
            header,
            success: (res) => {
                resolve(res)
            }
        })

    })
}
// request.beseUrl = "https://www.zhengzhicheng.cn/api/public/v1/"
request.beseUrl = "https://autumnfish.cn/wx/api/public/v1/"
request.get = function(url, data) {
    return request(request.beseUrl + url, 'GET', data)
}
request.post = function(url, data) {
    return request(request.beseUrl + url, 'POST', data)
}
request.auth = function(url, data) {
    const token = wx.getStorageSync("token");
    if (token) {
        return request(request.beseUrl + url, 'POST', data, { Authorization: token })
    } else {
        wx.navigateTo({ url: '/pages/auth/main' });
        return new Promise(() => {})

    }

}
request.auth.get = function(url, data) {
    const token = wx.getStorageSync("token");
    if (token) {
        return request(request.beseUrl + url, 'GET', data, { Authorization: token })
    } else {
        wx.navigateTo({ url: '/pages/auth/main' });
        return new Promise(() => {})

    }

}
export default request